/*   **********************************************************************  **
 **   Copyright notice                                                       **
 **                                                                          **
 **   (c) 2009, Around(J2)ME				                                 **
 **   All rights reserved.                                                   **
 **                                                                          **
 **   This program and the accompanying materials are made available under   **
 **   the terms of the New BSD License which accompanies this    			 **
 **   distribution.											                 **
 **   A copy is found in the textfile LICENSE.txt							 **
 **                                                                          **
 **   This copyright notice MUST APPEAR in all copies of the file!           **
 **                                                                          **
 **   Main developers:                                                       **
 **     Juri Strumpflohner		http://blog.js-development.com	             **
 **		Matthias Braunhofer		http://matthias.jimdo.com                    **
 **                                                                          **
 **  **********************************************************************  */

package com.firstlife.mps.unittests;

import j2meunit.framework.Test;
import j2meunit.framework.TestCase;
import j2meunit.framework.TestMethod;
import j2meunit.framework.TestSuite;

import java.io.IOException;

import com.aroundj2me.utility.StringReplacer;

public class StringReplacerTest extends TestCase {
	private StringReplacer replacer;
	private String string;
	private String replaceString;
	private String replaceWith;
	private String expected;
	
	public StringReplacerTest() {
	}
	
	public StringReplacerTest(String name, TestMethod method) {
		super(name, method);
	}
	
	protected void setUp() throws Exception {
		replacer = new StringReplacer();
		string = "&test";
		replaceString = "&";
		replaceWith = "&amp;";
		expected = "&amp;test";
	}
	
	protected void tearDown() throws Exception {
		replacer = null;
		string = null;
		replaceString = null;
		replaceWith = null;
		expected = null;
	}
	
	public void testReplace() {
		assertEquals("Outcome should be equals as expected", expected, replacer.replace(string, replaceString, replaceWith));
	}
	
	public Test suite() {
		TestSuite aSuite = new TestSuite();
		aSuite.addTest(new StringReplacerTest("StringReplacerTest:testReplace", new TestMethod() { 
			public void run(TestCase tc) throws IOException {
				((StringReplacerTest) tc).testReplace(); 
			} 
		}));
		return aSuite;
	}
}
